package com.example.WebSocketDemo.exception;

import com.example.WebSocketDemo.util.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLException;

//@ControllerAdvice
public class GlobalExceptionHandler {
    /**
     * 当web层中抛出异常时，统一处理，并返回指定的错误信息
     */
    @ExceptionHandler({NullPointerException.class,SQLException.class,ClassNotFoundException.class})
    @ResponseBody
    public Result handlerREST(){
        return new Result(10002,"系统内部错误");
    }
}
